package objects;

import java.util.ArrayList;

import parser.Entry;
import utils.Damage_skill_data;

public class Skill_duration {

	protected Long start;
	protected Long stop;
	protected Long duration;
	protected Long target;
	protected Long stack;
	protected ArrayList<Entry> actions;
	protected Damage_skill_data datas;  
	
	public Skill_duration(Long target){
		this.target = target;
		this.stack = Long.parseLong("0");
		this.actions = new ArrayList<Entry>();
	}

	public Long getStart() {
		return start;
	}

	public void setStart(Long start) {
		this.start = start;
	}

	public Long getStop() {
		return stop;
	}

	public void setStop(Long stop) {
		this.stop = stop;
	}

	public Long getTarget() {
		return target;
	}

	public void setTarget(Long target) {
		this.target = target;
	}

	public Long getStack() {
		return stack;
	}

	public void incrementStack() {
		this.stack++;
	}
	public void decrementStack(){
		this.stack--;
	}

	public ArrayList<Entry> getActions() {
		return actions;
	}

	public void setActions(ArrayList<Entry> actions) {
		this.actions = actions;
	}
	public void add_entry(Entry entry){
		this.actions.add(entry);
	}
	
	public void calculate_duration(){
		this.duration = this.stop-this.start;
	}
	
	public void setcalculation(){
		this.datas = new Damage_skill_data();

		for(int i = 0;i<this.actions.size();i++){
			//System.out.println(this.actions.get(i).getLine());
			if(this.actions.get(i).getMyskill().isCrit()){
				this.datas.incrementNb_crit(1);
				this.datas.incrementSum_crit(this.actions.get(i).getMyskill().getNumeric_value());
				this.datas.setCrit_max(this.actions.get(i).getMyskill().getNumeric_value());
				this.datas.setCrit_min(this.actions.get(i).getMyskill().getNumeric_value());
			}else{
				this.datas.incrmentNb_normal(1);
				this.datas.incrementSum_normal(this.actions.get(i).getMyskill().getNumeric_value());
				this.datas.setNormal_max(this.actions.get(i).getMyskill().getNumeric_value());
				this.datas.setNormal_min(this.actions.get(i).getMyskill().getNumeric_value());
			}
		}
		this.datas.calculateMoyenne();
		this.datas.calculateMoyenne_crit();
		this.datas.calculateMoyenne_normal();
	}

	public Long getDuration() {
		return duration;
	}

	public Damage_skill_data getDatas() {
		return datas;
	}
	
}
